package cn.vendpay.com.controller;


import cn.vendcommon.com.entity.Result;
import cn.vendpay.com.service.MinioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/minio")
public class MinioController {

    @Autowired
    private MinioService minioService;

    /**
     * 上传视频文件
     * @param file 视频文件
     * @param userId 用户ID
     * @param machineId 机器ID
     */
    @PostMapping("/upload")
    public Result<String> uploadVideo(
            @RequestParam("file") MultipartFile file,
            @RequestParam("userId") int userId,
            @RequestParam("machineId") int machineId) throws Exception {

        // 调用MinioService上传
        String fileUrl = minioService.uploadVideo(file, userId, machineId);

        // 返回文件访问地址
        return Result.success(fileUrl);
    }
}
